﻿using System;
using System.IO;
using System.Text;
using UmengSDK.Business;

namespace UmengAnalyticsNet.Extension
{
    public class PathEx
    {
        private static string _key;

        public static string GetAppDataPath()
        {
            var path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            var result = Path.Combine(path, "Umeng");

            return result;
        }

        public static string GetAppDataPath(string p_withPath)
        {
            var path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            var result = Path.Combine(path, "Umeng", p_withPath);

            return result;
        }

        public static string GetAppDataPathWithKey(string p_path)
        {
            var path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            if (string.IsNullOrEmpty(_key))
            {
                _key = MD5Core.GetHashString(Manager.AppKey + Manager.Channel, Encoding.UTF8);
            }

            var result = Path.Combine(path, "Umeng", _key, p_path);

            return result;
        }
    }
}